package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.DamageList;
import com.atguigu.jxc.service.DamageListGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("damageListGoods")
@Slf4j
public class DamageListGoodsController {
    @Autowired
    private DamageListGoodsService damageListGoodsService;

    /**
     * 保存报损单
     *
     * @param damageList
     * @param damageListGoodsStr
     * @return
     */
    @PostMapping("save")
    public ServiceVO save(DamageList damageList, String damageListGoodsStr) {
        return damageListGoodsService.save(damageList, damageListGoodsStr);
    }


    /**
     * 查询报损单
     *
     * @param sTime
     * @param eTime
     * @return
     */
    @PostMapping("list")
    public Map<String, Object> list(String sTime, String eTime) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("rows", damageListGoodsService.list(sTime, eTime));
        return map;
    }

    /**
     * 查询报损单中的报损商品
     *
     * @param damageListId
     * @return
     */
    @PostMapping("goodsList")
    public Map<String, Object> goodsList(Integer damageListId) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("rows",damageListGoodsService.goodsList(damageListId));
        return map;
    }
}
